plat/arm/sgi: Use platform specific functions to get platform ids
authorChandni Cherukuri <[email protected]>
Wed, 28 Nov 2018 06:01:51 +0000 (11:31 +0530)
committerChandni Cherukuri <[email protected]>
Mon, 3 Dec 2018 13:05:50 +0000 (18:35 +0530)
Add two new functions 'plat_arm_sgi_get_platform_id' and
'plat_arm_sgi_get_config_id' which will be implemented by all the
SGI platforms. These functions can be used to determine the part
number and configuration id of the SGI platforms.

In BL2, these functions are used to populate the 'system-id' node.
In BL31, these functions are used to populate the 'sgi_plat_info_t'
structure with the part number and configuration id of the platform.

Change-Id: I3bacda933527724a3b4074ad4ed5b53a81ea4689
Signed-off-by: Chandni Cherukuri <[email protected]>
plat/arm/board/sgi575/platform.mk
plat/arm/board/sgi575/sgi575_plat.c [new file with mode: 0644]
plat/arm/board/sgiclarka/platform.mk
plat/arm/board/sgiclarka/sgiclarka_plat.c [new file with mode: 0644]
plat/arm/css/sgi/include/sgi_variant.h
plat/arm/css/sgi/sgi_bl31_setup.c
plat/arm/css/sgi/sgi_image_load.c

index dd82d2975f61d37e3d666487a9b7f228b648b648..f31a8b730c0f891140338e9243f0775990bae0d7 100644 (file)
@@ -14,12 +14,14 @@ SGI_CPU_SOURCES             :=      lib/cpus/aarch64/cortex_a75.S
 
 BL1_SOURCES            +=      ${SGI_CPU_SOURCES}
 
-BL2_SOURCES            +=      ${SGI575_BASE}/sgi575_security.c        \
+BL2_SOURCES            +=      ${SGI575_BASE}/sgi575_plat.c            \
+                               ${SGI575_BASE}/sgi575_security.c        \
                                drivers/arm/tzc/tzc_dmc620.c            \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
 
 BL31_SOURCES           +=      ${SGI_CPU_SOURCES}                      \
+                               ${SGI575_BASE}/sgi575_plat.c            \
                                drivers/cfi/v2m/v2m_flash.c             \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/sgi575/sgi575_plat.c b/plat/arm/board/sgi575/sgi575_plat.c
new file mode 100644 (file)
index 0000000..a8ca916
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform.h>
+
+unsigned int plat_arm_sgi_get_platform_id(void)
+{
+       return mmio_read_32(SSC_VERSION) & SSC_VERSION_PART_NUM_MASK;
+}
+
+unsigned int plat_arm_sgi_get_config_id(void)
+{
+       return (mmio_read_32(SSC_VERSION) >> SSC_VERSION_CONFIG_SHIFT)
+                       & SSC_VERSION_CONFIG_MASK;
+}
index cf02219fb9713f0fc3f85a5bdbb09d8cd9f19e69..0773be5bbbee78be65d2345635ba4bb288eeda8d 100644 (file)
@@ -14,12 +14,14 @@ SGI_CPU_SOURCES             :=      lib/cpus/aarch64/cortex_ares.S
 
 BL1_SOURCES            +=      ${SGI_CPU_SOURCES}
 
-BL2_SOURCES            +=      ${SGICLARKA_BASE}/sgiclarka_security.c  \
+BL2_SOURCES            +=      ${SGICLARKA_BASE}/sgiclarka_plat.c      \
+                               ${SGICLARKA_BASE}/sgiclarka_security.c  \
                                drivers/arm/tzc/tzc_dmc620.c            \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
 
 BL31_SOURCES           +=      ${SGI_CPU_SOURCES}                      \
+                               ${SGICLARKA_BASE}/sgiclarka_plat.c      \
                                drivers/cfi/v2m/v2m_flash.c             \
                                lib/utils/mem_region.c                  \
                                plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/sgiclarka/sgiclarka_plat.c b/plat/arm/board/sgiclarka/sgiclarka_plat.c
new file mode 100644 (file)
index 0000000..3df2da6
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform.h>
+
+unsigned int plat_arm_sgi_get_platform_id(void)
+{
+       return mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
+                               & SID_SYSTEM_ID_PART_NUM_MASK;
+}
+
+unsigned int plat_arm_sgi_get_config_id(void)
+{
+       return mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
+}
index dea580be27dd1768f7cb77af56f112e73f0776a0..56dc33449d130762707592d7bf3d2527eb05c6a9 100644 (file)
@@ -21,4 +21,10 @@ typedef struct sgi_platform_info {
 
 extern sgi_platform_info_t sgi_plat_info;
 
+/* returns the part number of the platform*/
+unsigned int plat_arm_sgi_get_platform_id(void);
+
+/* returns the configuration id of the platform */
+unsigned int plat_arm_sgi_get_config_id(void);
+
 #endif /* SGI_VARIANT_H */
index d44f89c76b4df26fa790b7549a15171fb4da017c..a254388b5d3a5b4694532b2fa1ba4a5a53053c70 100644 (file)
@@ -42,53 +42,11 @@ scmi_channel_plat_info_t *plat_css_get_scmi_info()
                panic();
 };
 
-/*******************************************************************************
- * This function sets the sgi_platform_id and sgi_config_id
- ******************************************************************************/
-int sgi_identify_platform(unsigned long hw_config)
-{
-       void *fdt;
-       int nodeoffset;
-       const unsigned int *property;
-
-       fdt = (void *)hw_config;
-
-       /* Check the validity of the fdt */
-       assert(fdt_check_header(fdt) == 0);
-
-       nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
-       if (nodeoffset < 0) {
-               ERROR("Failed to get system-id node offset\n");
-               return -1;
-       }
-
-       property = fdt_getprop(fdt, nodeoffset, "platform-id", NULL);
-       if (property == NULL) {
-               ERROR("Failed to get platform-id property\n");
-               return -1;
-       }
-
-       sgi_plat_info.platform_id = fdt32_to_cpu(*property);
-
-       property = fdt_getprop(fdt, nodeoffset, "config-id", NULL);
-       if (property == NULL) {
-               ERROR("Failed to get config-id property\n");
-               return -1;
-       }
-
-       sgi_plat_info.config_id = fdt32_to_cpu(*property);
-
-       return 0;
-}
-
 void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
                                u_register_t arg2, u_register_t arg3)
 {
-       int ret;
-
-       ret = sgi_identify_platform(arg2);
-       if (ret == -1)
-               panic();
+       sgi_plat_info.platform_id = plat_arm_sgi_get_platform_id();
+       sgi_plat_info.config_id = plat_arm_sgi_get_config_id();
 
        arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3);
 }
index d97583ef9fa7e3a01aeb39090f0631985e0395db..39069ca3ece9d47319a1117927405e452d2f2a4b 100644 (file)
@@ -9,6 +9,7 @@
 #include <desc_image_load.h>
 #include <libfdt.h>
 #include <platform.h>
+#include <sgi_variant.h>
 
 /*******************************************************************************
  * This function inserts Platform information via device tree nodes as,
@@ -23,7 +24,6 @@ static int plat_sgi_append_config_node(void)
        void *fdt;
        int nodeoffset, err;
        unsigned int platid = 0, platcfg = 0;
-       char *platform_name;
 
        mem_params = get_bl_mem_params_node(HW_CONFIG_ID);
        if (mem_params == NULL) {
@@ -39,38 +39,20 @@ static int plat_sgi_append_config_node(void)
                return -1;
        }
 
-       platform_name = (char *)fdt_getprop(fdt, 0, "compatible", NULL);
-
-       if (platform_name == NULL) {
-               ERROR("Invalid HW_CONFIG DTB passed\n");
-               return -1;
-       }
-
-       if (strcmp(platform_name, "arm,sgi575") == 0) {
-               platid = mmio_read_32(SSC_VERSION) & SSC_VERSION_PART_NUM_MASK;
-               platcfg = (mmio_read_32(SSC_VERSION) >> SSC_VERSION_CONFIG_SHIFT)
-                               & SSC_VERSION_CONFIG_MASK;
-       } else if (strcmp(platform_name, "arm,sgi-clark") == 0) {
-               platid = mmio_read_32(SID_REG_BASE + SID_SYSTEM_ID_OFFSET)
-                               & SID_SYSTEM_ID_PART_NUM_MASK;
-               platcfg = mmio_read_32(SID_REG_BASE + SID_SYSTEM_CFG_OFFSET);
-       } else {
-               WARN("Invalid platform\n");
-               return -1;
-       }
-
        nodeoffset = fdt_subnode_offset(fdt, 0, "system-id");
        if (nodeoffset < 0) {
                ERROR("Failed to get system-id node offset\n");
                return -1;
        }
 
+       platid = plat_arm_sgi_get_platform_id();
        err = fdt_setprop_u32(fdt, nodeoffset, "platform-id", platid);
        if (err < 0) {
                ERROR("Failed to set platform-id\n");
                return -1;
        }
 
+       platcfg = plat_arm_sgi_get_config_id();
        err = fdt_setprop_u32(fdt, nodeoffset, "config-id", platcfg);
        if (err < 0) {
                ERROR("Failed to set config-id\n");